package com.jt.config;

import com.jt.pojo.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

@Configuration  //标识这是一个配置类，相当于application.xml
@ComponentScan("com.jt")    //如果注解中只有value属性，则可省略
@PropertySource(value="classpath:/user.properties",encoding = "utf-8")
public class SpringConfig {
    @Value("${user.id}")
    private Integer id;
    @Value("${user.username}")
    private String username;

    @Bean
    public User user(){
        User user = new User();
        user.setId(id);
        user.setUsername(username);
        return user;
    }

}
